#  -*- coding = utf-8 -*-
# @Time :  22:05
# @Author: blackshark
#@File :dataBaseCreate.py
#@SoftWare : PyCharm

import pymysql
import educationCrawler
import 党委学生部

# table="education"
# imgTable="imageForEducation"
table="partyCommittee"
imgTable="imageForPartyCommittee"
id="id"
title="title"
information="information"
passage="passage"
num="num"
image="image"


db=pymysql.connect(host="120.78.179.141",user="newsForCrawler",password="imtired",database="newsforcrawler")
cursor=db.cursor()
# cursor.execute("SELECT VERSION()")
# data = cursor.fetchone()
# print ("Database version : %s " % data)


# for i in range(30):
#     sql='INSERT INTO {table}({id},{title},{information},{passage},{num}) VALUES ({values1},{values2},{values3},{values4},{values6})'.format(
#         table=table,id=id,title=title,information=information,passage=passage,num=num,
#         values1=i+1,values2=str('\'')+educationCrawler.title[i]+str('\''),values3=str('\'')+educationCrawler.information[i]+str('\''),
#         values4=str('\'')+educationCrawler.passage[i]+str('\''),values6=educationCrawler.pagePicNum[i])
#     cursor.execute(sql)
# for j in range(len(educationCrawler.imgUrl)):
#     sql='INSERT INTO {table}({id},{image}) VALUES ({values1},{values2})'.format(
#         table=imgTable,id=id,image=image,values1=j+1,values2=str('\'') + educationCrawler.imgUrl[j] + str('\''))
#     cursor.execute(sql)

# for i in range(30):
#     sql='INSERT INTO {table}({id},{title},{information},{passage},{num}) VALUES ({values1},{values2},{values3},{values4},{values6})'.format(
#         table=table,id=id,title=title,information=information,passage=passage,num=num,
#         values1=i+1,values2=str('\'')+党委学生部.title[i]+str('\''),values3=str('\'')+党委学生部.information[i]+str('\''),
#         values4=str('\'')+党委学生部.passage[i]+str('\''),values6=党委学生部.pagePicNum[i])
#     cursor.execute(sql)
#
# for j in range(len(党委学生部.imgUrl)):
#     sql='INSERT INTO {table}({id},{image}) VALUES ({values1},{values2})'.format(
#         table=imgTable,id=id,image=image,values1=j+1,values2=str('\'') + str(党委学生部.imgUrl[j]) + str('\''))
#     cursor.execute(sql)


# sql="select * from education where id=1"
# sql2="select * from education where id=2"
# cursor.execute(sql)
# cursor.execute(sql2)
# res = cursor.fetchall()
# print(res)
db.commit()
db.close()

#
#
#
#
#